<template>
    <view
        @tap="__e"
        @touchmove.stop.prevent="__e"
        class="mask data-v-695af478"
        :data-event-opts="[
            ['tap', [['cancel', ['$event']]]],
            ['touchmove', [['', ['$event']]]]
        ]"
    >
        <view @tap.stop.prevent="__e" class="mask-content animated bounceInUp data-v-695af478" :data-event-opts="[['tap', [['', ['$event']]]]]">
            <view @tap="__e" class="data-v-695af478" :data-event-opts="[['tap', [['cancel', ['$event']]]]]">
                <text class="new-iconfont icon-arrow-down iconText data-v-695af478"></text>
            </view>
            <view class="data-v-695af478" style="display: flex; justify-content: space-between; border-bottom: 2rpx solid #323041; padding-bottom: 24rpx; align-items: center">
                <view class="data-v-695af478" style="font-size: 32rox; color: #ffffff">
                    {{ '' + info.title + '' }}
                    <view class="price data-v-695af478" style="color: #1884fe; margin-top: 16rpx">
                        <text class="data-v-695af478">单价</text>
                        <price-display @__l="__l" class="data-v-695af478" :info="info" vueId="0b4c2d28-1"></price-display>
                    </view>
                </view>
                <view class="data-v-695af478" style="font-size: 32rpx; color: #ffffff">
                    <text class="data-v-695af478">×</text>
                    <text class="data-v-695af478" style="margin-left: 14rpx">{{ payTotal + '张' }}</text>
                </view>
            </view>
            <view class="block data-v-695af478" style="display: flex">
                <view class="item-title data-v-695af478">可用优惠券:</view>
                <view @tap="__e" class="arrow-right bold data-v-695af478" :data-event-opts="[['tap', [['showPopup', ['$event']]]]]">
                    <text class="meta data-v-695af478" v-if="order.coupon_discount">{{ '-¥' + $root.g0 }}</text>
                    <block v-else>
                        <text class="meta data-v-695af478" style="color: #ff1a1a" v-if="$root.g1">{{ $root.g2 + '张可用' }}</text>
                        <text class="meta gray-text data-v-695af478" v-else>暂无可用优惠券</text>
                    </block>
                    <text class="new-iconfont icon-arrow-right data-v-695af478"></text>
                </view>
            </view>
            <view class="block data-v-695af478">
                <view class="item-title data-v-695af478">
                    余额:
                    <text class="data-v-695af478" style="color: #ef563d; font-size: 24rpx"></text>
                </view>
                <view class="arrow-right bold data-v-695af478" style="display: flex">
                    <block v-if="order.redpack">
                        <text class="meta data-v-695af478">{{ '¥' + $root.g3 }}</text>
                        <checkbox-group @change="__e" class="data-v-695af478" :data-event-opts="[['change', [['switchChange', ['$event']]]]]" style="margin-top: -4rpx">
                            <label class="data-v-695af478">
                                <checkbox
                                    :checked="order.is_use_redpack"
                                    class="redpack-switch checkbox-backgroun-yellow checkbox-round data-v-695af478"
                                    color="#5ac725"
                                    :value="order.is_use_redpack"
                                ></checkbox>
                            </label>
                        </checkbox-group>
                    </block>
                    <text class="meta data-v-695af478" v-else>¥0</text>
                </view>
            </view>
            <view class="block data-v-695af478">
                <view class="item-title data-v-695af478">
                    可用
                    <text class="data-v-695af478" style="color: #ef563d">{{ order.max_useable_score }}</text>
                    {{ scoreAlias }}
                </view>
                <view class="arrow-right bold data-v-695af478" style="display: flex">
                    <text class="meta red data-v-695af478" style="margin-left: 10rpx" v-if="order.max_useable_score && form.is_use_score">{{ '-¥' + $root.f0 }}</text>
                    <checkbox-group @change="__e" class="data-v-695af478" :data-event-opts="[['change', [['scoreSwitchChange', ['$event']]]]]" style="margin-top: -4rpx">
                        <label class="data-v-695af478">
                            <checkbox
                                :checked="form.is_use_score"
                                class="redpack-switch checkbox-backgroun-yellow checkbox-round data-v-695af478"
                                color="#5ac725"
                                :value="form.is_use_score"
                            ></checkbox>
                        </label>
                    </checkbox-group>
                </view>
            </view>
            <view class="block data-v-695af478" v-if="doubleBoxCard.is_show && doubleBoxCard.my_balance > 0 && payTotal <= 10">
                <view class="item-title data-v-695af478">
                    {{ doubleBoxCard.double_card_info.title }}
                    <text class="data-v-695af478" style="color: #ef563d; font-size: 24rpx">(抽赏所获金额翻倍!)</text>
                </view>
                <view class="arrow-right bold data-v-695af478">
                    <checkbox-group @change="__e" class="data-v-695af478" :data-event-opts="[['change', [['doubleBoxCardswitchChange', ['$event']]]]]" style="margin-top: -4rpx">
                        <label class="data-v-695af478">
                            <checkbox
                                :checked="form.is_doubleBoxCard"
                                class="redpack-switch checkbox-backgroun-yellow checkbox-round data-v-695af478"
                                color="#5ac725"
                                :value="form.is_doubleBoxCard"
                            ></checkbox>
                        </label>
                    </checkbox-group>
                </view>
            </view>
            <view class="total data-v-695af478">
                <text class="data-v-695af478">购买数量</text>
                <text class="data-v-695af478">{{ payTotal }}</text>
                <text class="data-v-695af478">
                    发
                    <text class="data-v-695af478" style="color: #1884fe; margin-left: 16rpx">共计</text>
                </text>
                <price-display
                    @__l="__l"
                    class="data-v-695af478"
                    :info="order"
                    prefix="pay_"
                    style="font-size: 46rpx; font-weight: 200; color: #1884fe"
                    vueId="0b4c2d28-2"
                ></price-display>
            </view>
            <view class="data-v-695af478" style="color: #ffffff; font-size: 20rpx">
                注意：
                <view class="data-v-695af478">1、发货需要10元邮资，没有包邮，非预售产品15天工作日发出；</view>
                <view class="data-v-695af478">2、潮玩开赏存在概率性，不支持退款，请谨慎消费，未成年禁止消费。</view>
            </view>
            <view
                @tap="__e"
                class="button data-v-695af478"
                :data-event-opts="[['tap', [['disableMultiClick', ['$0'], ['submit']]]]]"
                v-if="isInit && !isLoading && isCheckUserStatement"
            ></view>
            <view class="button data-v-695af478" v-else></view>
            <user-statement
                @__l="__l($event, { eventOpts: [['^input', [['__set_model', ['', 'isCheckUserStatement', '$event', []]]]]] })"
                @input="__e($event, { eventOpts: [['^input', [['__set_model', ['', 'isCheckUserStatement', '$event', []]]]]] })"
                class="data-v-695af478"
                :data-event-opts="[['^input', [['__set_model', ['', 'isCheckUserStatement', '$event', []]]]]]"
                :value="isCheckUserStatement"
                vueId="0b4c2d28-3"
            ></user-statement>
        </view>
        <usable-coupon-popup
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^change', [['couponChange']]],
                        ['^close', [['hidePopup']]],
                        ['^load', [['load']]]
                    ]
                })
            "
            @change="
                __e($event, {
                    eventOpts: [
                        ['^change', [['couponChange']]],
                        ['^close', [['hidePopup']]],
                        ['^load', [['load']]]
                    ]
                })
            "
            @close="
                __e($event, {
                    eventOpts: [
                        ['^change', [['couponChange']]],
                        ['^close', [['hidePopup']]],
                        ['^load', [['load']]]
                    ]
                })
            "
            @load="
                __e($event, {
                    eventOpts: [
                        ['^change', [['couponChange']]],
                        ['^close', [['hidePopup']]],
                        ['^load', [['load']]]
                    ]
                })
            "
            class="data-v-695af478"
            :data-event-opts="[
                ['^change', [['couponChange']]],
                ['^close', [['hidePopup']]],
                ['^load', [['load']]]
            ]"
            :unusableCoupons="unusableCouponsList"
            :usableCoupons="usableCouponsList"
            vueId="0b4c2d28-4"
            v-if="isCouponPopup"
        ></usable-coupon-popup>
    </view>
</template>

<script>
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import userStatement from '@/components/UserStatement/UserStatement';
import usableCouponPopup from '@/components/UsableCouponPopup/UsableCouponPopup';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/wuxianshang/components/PayCard'],
    {
        '2b9b': function (o, e, t) {
            'use strict';

            var n = t('9e94');
            t.n(n).a;
        },
        '578e': function (o, e, t) {
            'use strict';

            t.d(e, 'b', function () {
                return i;
            });
            t.d(e, 'c', function () {
                return s;
            });
            t.d(e, 'a', function () {
                return n;
            });
            var n = {
                PriceDisplay: function () {
                    return t.e('components/PriceDisplay/PriceDisplay').then(t.bind(null, '6b05'));
                },
                UserStatement: function () {
                    return t.e('components/UserStatement/UserStatement').then(t.bind(null, '72e8'));
                },
                UsableCouponPopup: function () {
                    return t.e('components/UsableCouponPopup/UsableCouponPopup').then(t.bind(null, '3858'));
                }
            };
            var i = function () {
                var that = this;
                var e = (that.$createElement, that._self._c, that.order.coupon_discount ? that.$tool.formatPrice(that.order.coupon_discount) : null);
                if (that.order.coupon_discount) {
                    var t = null;
                } else {
                    var t = that.usableCoupons.length;
                }
                if (!that.order.coupon_discount && t) {
                    var n = that.usableCoupons.length;
                } else {
                    var n = null;
                }
                var i = that.order.redpack ? that.$tool.formatPrice(that.order.redpack) : null;
                var s = that.order.max_useable_score && that.form.is_use_score ? that._f('priceToFixed')(that.order.score_discount) : null;
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            g0: e,
                            g1: t,
                            g2: n,
                            g3: i,
                            f0: s
                        }
                    }
                );
            };
            var s = [];
        },
        '8e92a': function (o, e, t) {
            'use strict';

            t.r(e);
            var n = t('a3b9');
            var i = t.n(n);
            for (var s in n) {
                if (['default'].indexOf(s) < 0) {
                    (function (o) {
                        t.d(e, o, function () {
                            return n[o];
                        });
                    })(s);
                }
            }
            e.default = i.a;
        },
        '9e94': function (o, e, t) {},
        a3b9: function (o, e, t) {
            'use strict';

            (function (o) {
                var n = t('4ea4');
                Object.defineProperty(e, '__esModule', {
                    value: true
                });
                e.default = void 0;
                var i = n(t('9523'));
                var s = t('26cb');
                var r = n(t('82c0'));
                function u(o, e) {
                    var t = Object.keys(o);
                    if (Object.getOwnPropertySymbols) {
                        var n = Object.getOwnPropertySymbols(o);
                        if (e) {
                            n = n.filter(function (e) {
                                return Object.getOwnPropertyDescriptor(o, e).enumerable;
                            });
                        }
                        t.push.apply(t, n);
                    }
                    return t;
                }
                function a(o) {
                    for (var e = 1; e < arguments.length; e++) {
                        var t = null != arguments[e] ? arguments[e] : {};
                        e % 2
                            ? u(Object(t), true).forEach(function (e) {
                                  (0, i.default)(o, e, t[e]);
                              })
                            : Object.getOwnPropertyDescriptors
                            ? Object.defineProperties(o, Object.getOwnPropertyDescriptors(t))
                            : u(Object(t)).forEach(function (e) {
                                  Object.defineProperty(o, e, Object.getOwnPropertyDescriptor(t, e));
                              });
                    }
                    return o;
                }
                var c = {
                    components: {},
                    data: function () {
                        return {
                            payTotal: -1,
                            order: {},
                            price: 0,
                            form: {
                                is_use_redpack: 1,
                                is_use_score: 1,
                                is_doubleBoxCard: 0
                            },
                            total_prices: 0,
                            total_score_price: 0,
                            currentCoupon: {},
                            isCouponPopup: false,
                            unusableCoupons: [],
                            usableCoupons: [],
                            usableCouponsList: [],
                            unusableCouponsList: [],
                            isInit: false,
                            isLoading: false,
                            isSubmiting: false,
                            isCheckUserStatement: true,
                            doubleBoxCard: {},
                            count: 10
                        };
                    },
                    props: {
                        info: {
                            type: Object
                        }
                    },
                    computed: a(
                        a({}, (0, s.mapGetters)(['userInfo'])),
                        {},
                        {
                            isuserInfo: function () {
                                console.log(this.userInfo);
                            }
                        }
                    ),
                    watch: {
                        payTotal: function () {
                            this.initOrder();
                        }
                    },
                    created: function () {
                        this.payTotal = this.info.pay_total;
                        console.log('info', this.info);
                        var that = this;
                        o.getStorage({
                            key: 'fudai_scoreStorage',
                            success: function (o) {
                                that.form.is_use_score = o.data ? 1 : 0;
                                setTimeout(function () {
                                    that.initOrder();
                                }, 100);
                            }
                        });
                    },
                    methods: {
                        load: function () {
                            this.count += 10;
                            console.log(this.count);
                            this.showPopup();
                        },
                        showPopup: function () {
                            for (o = [], e = [], t = 0, void 0; t < this.count; t++) {
                                var o;
                                var e;
                                var t;
                                if (void 0 !== this.usableCoupons[t]) {
                                    o.push(this.usableCoupons[t]);
                                }
                                if (void 0 !== this.unusableCoupons[t]) {
                                    e.push(this.unusableCoupons[t]);
                                }
                            }
                            this.usableCouponsList = o.filter(function (o, e, t) {
                                return (
                                    t.findIndex(function (e) {
                                        return e.id === o.id;
                                    }) === e
                                );
                            });
                            this.unusableCouponsList = e.filter(function (o, e, t) {
                                return (
                                    t.findIndex(function (e) {
                                        return e.id === o.id;
                                    }) === e
                                );
                            });
                            this.isCouponPopup = true;
                        },
                        hidePopup: function () {
                            this.count = 10;
                            this.usableCouponsList = [];
                            this.unusableCouponsList = [];
                            this.isCouponPopup = false;
                        },
                        couponChange: function (o) {
                            o.id === this.currentCoupon.id || ((this.currentCoupon = o), this.initOrder());
                        },
                        initOrder: function () {
                            var that = this;
                            o.showLoading();
                            this.$http(
                                '/fudai/order/preview',
                                'POST',
                                a(
                                    {
                                        page_uuid: this.info.page_uuid,
                                        total: this.payTotal,
                                        coupon_id: this.currentCoupon.id
                                    },
                                    this.form
                                )
                            )
                                .then(function (t) {
                                    that.isInit = true;
                                    that.order = t.data.order;
                                    that.unusableCoupons = t.data.order.coupons.unusable;
                                    that.usableCoupons = t.data.order.coupons.usable;
                                    console.log('order=>', t.data.order);
                                    o.hideLoading();
                                })
                                .catch(function (o) {
                                    that.isInit = false;
                                    that.cancel();
                                });
                            this.$http('/user/cards').then(function (o) {
                                that.doubleBoxCard = o.data.double_box_card;
                                console.log(o.data.double_box_card);
                            });
                        },
                        switchChange: function (o) {
                            null == o.detail.value[0] ? (this.form.is_use_redpack = 0) : (this.form.is_use_redpack = 1);
                            this.initOrder();
                        },
                        scoreSwitchChange: function (e) {
                            console.log(e);
                            this.form.is_use_score = !(e.detail.value.length > 1);
                            null == e.detail.value[0]
                                ? ((this.form.is_use_score = 0),
                                  o.setStorage({
                                      key: 'fudai_scoreStorage',
                                      data: false,
                                      success: function () {
                                          console.log('success');
                                      }
                                  }))
                                : ((this.form.is_use_score = 1),
                                  o.setStorage({
                                      key: 'fudai_scoreStorage',
                                      data: true,
                                      success: function () {
                                          console.log('success');
                                      }
                                  }));
                            console.log(this.form.is_use_score);
                            this.initOrder();
                        },
                        doubleBoxCardswitchChange: function (o) {
                            1 === this.form.is_doubleBoxCard ? (this.form.is_doubleBoxCard = 0) : (this.form.is_doubleBoxCard = 1);
                            this.initOrder();
                        },
                        cancel: function () {
                            this.$emit('close');
                        },
                        createOrder: function () {
                            var that = this;
                            if (this.isLoading) {
                                return false;
                            }
                            this.isLoading = true;
                            o.showLoading({
                                title: '提交中'
                            });
                            this.$http(
                                '/fudai/order/confirm',
                                'POST',
                                a(
                                    {
                                        page_uuid: this.info.page_uuid,
                                        total: this.payTotal,
                                        coupon_id: this.currentCoupon.id
                                    },
                                    this.form
                                )
                            )
                                .then(function (t) {
                                    o.hideLoading();
                                    that.isSubmiting = false;
                                    var n = t.data;
                                    console.log(n);
                                    n.is_need_pay
                                        ? r.default.pay(
                                              a(
                                                  a({}, n),
                                                  {},
                                                  {
                                                      success: function () {
                                                          that.$emit('success', n.order, false, n.is_doubleBoxCard);
                                                      },
                                                      fail: function () {
                                                          o.showToast({
                                                              title: '支付失败',
                                                              icon: 'none'
                                                          });
                                                          that.$http('/orders/'.concat(n.order.uuid), 'PUT', {
                                                              type: 'close_and_delete'
                                                          });
                                                      }
                                                  }
                                              )
                                          )
                                        : that.$emit('success', n.order, false, n.is_doubleBoxCard);
                                })
                                .catch(function (o) {
                                    that.isLoading = false;
                                });
                        },
                        submit: function () {
                            if (this.isLoading) {
                                return false;
                            }
                            this.createOrder();
                        }
                    },
                    onPageScroll: function (o) {}
                };
                e.default = c;
            }.call(this, t('543d').default));
        },
        e99a: function (o, e, t) {
            'use strict';

            t.r(e);
            var n = t('578e');
            var i = t('8e92a');
            for (var s in i) {
                if (['default'].indexOf(s) < 0) {
                    (function (o) {
                        t.d(e, o, function () {
                            return i[o];
                        });
                    })(s);
                }
            }
            t('2b9b');
            var r = t('f0c5');
            var u = Object(r.a)(i.default, n.b, n.c, false, null, '695af478', null, false, n.a, void 0);
            e.default = u.exports;
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'pages/wuxianshang/components/PayCard-create-component',
    {
        'pages/wuxianshang/components/PayCard-create-component': function (o, e, t) {
            t('543d').createComponent(t('e99a'));
        }
    },
    [['pages/wuxianshang/components/PayCard-create-component']]
]);
</script>
<style>
@import './PayCard.css';
</style>
